export default {
    goods: {
        $cn:"商品",
        name: {
        },
        price: {
        }
    },
    store:{
        $cn:"商店",
        name:{},
    },
    user:{
        $cn:"用户",
        name:""
    },

    //  orderGoods: {
    //    $include: {
    //      model: "goods",
    //      fields: ["name", "price"]
    //    }
    //  },
    order: {
        $cn:"订单",
        buyer: {
            $from: {
                model: "user",
                fields: [
                    "id","name"
                ]
            }
        },
        store: {
            $from: {
                model: "store",
                fields: [
                    "id","name"
                ]
            }
        },
        orderGoods: {
            $array: true,
            $from: {
                model: "goods",
                fields: [
                    "name",
                    "price"
                ]
            },
            count: {
            }
        },
        totalAmount: {
            $calculate: function (ctx) {
                return ctx.get("goodsAmount") + 10;
            }
        },
        goodsAmount: {
            $calculate: function (context) {
                var total = 0;
                var item = context.get("orderGoods");
                for(var i = 0; i < items.length; i++){
                    total += item[i].price;
                }
                return total;
            }
        }
    }
}